Using State Listeners

Earlier in the training, we created DOFServer and DOFConnection instances using synchronous start and connect calls. However, the library also provides non-blocking asynchronous calls that you can use for this purpose.

You can also use connection and server state listeners to monitor the status of your components. These allow you to attempt to restart the server or reconnect the connection if they go down.

Note: The code for the connection state listener is similar to the server state listener.